<?php
/*
 * index.php
 *
 * Copyright (c) 2007 Marcelo Lira dos Santos
 *
 * Author: Marcelo Lira dos Santos <setanta@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

require_once 'activity.php';
require_once 'activity_collection.php';

$col = new ActivityCollection();

$activity_list = $col->get_list();

$page = implode('', file('template.html'));
$table = implode('', file('atividades_tabela.html'));
$row_templ = implode('', file('atividades_linha.html'));

$rows = '';
foreach ($activity_list as $item) {
    $row = str_replace('_ID', $item[0], $row_templ);
    $row = str_replace('_TITLE', $item[1], $row);
    $row = str_replace('_AUTHOR', $item[2], $row);
    $row = str_replace('_DESCRIPTION', $item[3], $row);
    $row = str_replace('_SOFTWARE', $item[4], $row);
    $rows = $rows . $row;
}
$table = str_replace('_ROWS', $rows, $table);

print str_replace('_CONTENTS', $table, $page);

//print "<pre>";
//print_r($activity_list);
//print "</pre>"

?>
